################################
#
#     Makefile Assegnamento 1 AA 2017/18
#    
################################


# file da consegnare
FILE_DA_CONSEGNARE=barnes.c

# preferenze compilatore e flag di compilazione
CC=gcc
# compilazione senza attesa
CFLAGS= -Wall -pedantic -g
# compilazione con attesa
#CFLAGS= -Wall -pedantic -g -DWAIT

obj = barnes.o barnes_d.o

# phony targets
.PHONY: cleanall test1 test2 test3 test4 consegna 


barn1 : 01test.o $(obj)
	gcc $(obj) 01test.o -o barn1 -lm

barn2 : 02test.o $(obj)
	gcc $(obj) 02test.o -o barn2 -lm

barn3 : 03test.o $(obj)
	gcc $(obj) 03test.o -o barn3 -lm

barn4 : 04test.o $(obj)
	gcc $(obj) 04test.o -o barn4 -lm

barn5 : 05test.o $(obj)
	gcc $(obj) 05test.o -o barn5 -lm


barnes.o: barnes.c barnes.h 
barnes_d.o: barnes_d.c barnes.h 
01test.o: 01test.c barnes.h  
02test.o: 02test.c barnes.h  
03test.o: 03test.c barnes.h  
04test.o: 04test.c barnes.h  
05test.o: 05test.c barnes.h  


cleanall: 
	-rm -f *.o *~ ./core barn?


test1:
	make cleanall
	make barn1
	-rm -f out1.txt
	./barn1 | tee out1.txt
	diff out1.txt DATI/out1.check
	@echo "********** Test1 superato!"

test2: 
	make cleanall
	make barn2
	-rm -f out2.txt
	./barn2 | tee out2.txt
	diff out2.txt DATI/out2.check
	@echo "********** Test2 superato!"


test3: 
	make cleanall
	make barn3
	-rm -f out3.txt
	./barn3 | tee out3.txt
	diff out3.txt DATI/out3.check
	@echo "********** Test3 superato!"


test4: 
	make cleanall
	make barn4
	-rm -f out4.txt
	./barn4 | tee out4.txt
	diff out4.txt DATI/out4.check
	@echo "********** Test4 superato!"




consegna:
	make cleanall
	make test1
	make test2
	make test3
	make test4
	./gruppo-check.pl < gruppo.txt
	tar -cvf $(USER)-a1.tar ./gruppo.txt  $(FILE_DA_CONSEGNARE) 
	@echo "********** TAR creato inviare in allegato a una mail al docente del proprio corso insieme a nome, cognome,  numero di matricola dei componenti del gruppo"
